package com.catmiao.spark.rdd.operator.transform

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @title: RDD_Operator_01_transform
 * @projectName spark_study
 * @description: TODO
 * @author ChengMiao
 * @date 2024/2/2 11:48
 */
object RDD_Operator_11_transform {

  def main(args: Array[String]): Unit = {
    val sparkCon = new SparkConf().setMaster("local[*]").setAppName("rdd")

    val sparkContext = new SparkContext(sparkCon)


    val rdd = sparkContext.makeRDD(List(2,3,4,5,6,1))

    // sortBy 排序
    /**
     * 会自动 shuffle，分区数不变
     *  param2: false-降序 true-升序
     */
    val newRdd = rdd.sortBy(i => i,false).collect()


    println(newRdd.mkString(","))

    sparkContext.stop()
  }

}
